# This file is part of MXE.
# See index.html for further information.

PKG             := mac
$(PKG)_IGNORE   :=
$(PKG)_CHECKSUM := bfcfc4b4b8f8b0bcf25ab7c6457af1d07b0505fb
$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE     := $($(PKG)_SUBDIR).tar.lzma
$(PKG)_URL      := http://opensourceliving.googlecode.com/files/$($(PKG)_FILE)
$(PKG)_DEPS     := gcc

define $(PKG)_UPDATE
    wget -q -O- 'http://code.google.com/p/opensourceliving/downloads/list?sort=-uploaded' | \
    $(SED) -n 's,.*mac-\([0-9][^<]*\)\.tar.lzma,\1,p' | \
    head -1 | awk -F\' '{print $1}'
endef

define $(PKG)_BUILD
    cd '$(1)' \
      && \
      MYVER=`echo '$(1)' | sed -n 's,.*mac-\([0-9][^<]*\)-1-mingw32-src,\1,p'` \
      tar -xf mac-`echo '$(1)' | sed -n 's,.*mac-\([0-9][^<]*\)-1-mingw32-src,\1,p'`.tar.gz \
      && patch -p1 < mac-`echo '$(1)' | sed -n 's,.*mac-\([0-9][^<]*\)-1-mingw32-src,\1,p'`-1.src.patch \
      && cd mac-`echo '$(1)' | sed -n 's,.*mac-\([0-9][^<]*\)-1-mingw32-src,\1,p'` \
      && CXXFLAGS='-DSHNTOOL -D_WIN32' ./configure \
        --host='$(TARGET)' \
        --prefix='$(PREFIX)/$(TARGET)' \
        --disable-shared \
        --disable-png \
        --disable-enca \
        --enable-fontconfig
    CXXFLAGS='-DSHNTOOL -D_WIN32' $(MAKE) -C "$(1)/mac-`echo '$(1)' | sed -n 's,.*mac-\([0-9][^<]*\)-1-mingw32-src,\1,p'`" -j '$(JOBS)'
    CXXFLAGS='-DSHNTOOL -D_WIN32' $(MAKE) -C "$(1)/mac-`echo '$(1)' | sed -n 's,.*mac-\([0-9][^<]*\)-1-mingw32-src,\1,p'`" -j 1 install
endef
